<template>
    <div class="app-container">
        <div class="head">
            <img src="@/assets/img/Layout/position.png" />
            <p class="see-block">BOM编辑</p>
        </div>
        <div class="view-container">
            <el-row class="status-title">
                <el-col class="mr20 width100">
                    <el-button
                        class="btn-success width100"
                        type="primary"
                        @click="submitForm()"
                    >提交</el-button>
                </el-col>
                <el-col :span="8" class="status-container">
                    <div class="status-item">
                        <span class="active">待审核</span>
                        <span>已审核</span>
                        <span>反审核</span>
                        <span>拒绝</span>
                    </div>
                </el-col>
            </el-row>
            <el-form ref="form" :model="form" :rules="rules" label-width="100px" class="mt30">
                <el-row>
                    <el-col :span="9">
                        <el-form-item label="单据编号:" prop="code">
                            <el-input v-model="form.code" placeholder="" :disabled="form.approvalStatus == '2' ? true : false" />
                        </el-form-item>
                    </el-col>
                    <el-col :span="9">
                        <el-form-item label="品名:" prop="specificationName">
                            <template v-if="form.approvalStatus !== '2'">
                                <el-input v-model="form.specificationName" placeholder="输入编码或名称模糊搜索" style="width:82%;" @input="onChangeName" />
                                <ul class="options" v-if="show" >
                                    <div class="options-item" v-if="skuProList.length > 0">
                                        <li @click="check(item)" v-for="item in skuProList" :key="item.id">
                                            {{ item.specificationCode + '—' + item.specificationName }}
                                        </li>
                                    </div>
                                </ul>
                                <el-button type="primary" size="small" class="btn-success" icon="el-icon-search" style="position:absolute;right:0;top:0;bottom:0;width:15%;font-size:14px;" @click="onBomSkuList"></el-button>
                            </template>
                            <template v-else>
                                <el-input v-model="form.specificationName" placeholder="" disabled />
                            </template>
                        </el-form-item>
                    </el-col>
                    <el-col :span="9">
                        <el-form-item label="规格:" prop="specification">
                            {{ form.specification }}
                        </el-form-item>
                    </el-col>
                    <el-col :span="9">
                        <el-form-item label="单位:" prop="unit">
                            {{ form.unit }}
                        </el-form-item>
                    </el-col>
                    <el-col :span="9">
                        <el-form-item label="生效时间:" prop="effectiveTime">
                            <el-date-picker value-format="yyyy-MM-dd HH:mm:ss" v-model="form.effectiveTime" suffix-icon="el-icon-date" type="datetime" placeholder="" :picker-options="pickerOptions" style="width:100%;" @change="onChangeEffectiveTime" />
                        </el-form-item>
                    </el-col>
                    <el-col :span="9">
                        <el-form-item label="失效时间:" prop="failureTime">
                            <el-date-picker value-format="yyyy-MM-dd HH:mm:ss" v-model="form.failureTime" suffix-icon="el-icon-date" type="datetime" placeholder="" :picker-options="pickerOptions" style="width:100%;" @change="onChangeFailureTime" />
                        </el-form-item>
                    </el-col>
                    <el-col :span="9">
                        <el-form-item label="版本号:" prop="version">
                            {{ form.version }}
                        </el-form-item>
                    </el-col>
                    <el-col :span="9">
                        <el-form-item label="备注:" prop="remark">
                            <el-input v-model="form.remark" placeholder="" />
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="24">
                        <el-table :data="productData">
                            <el-table-column label="序号" type="index" align="center" width="50" />
                            <el-table-column :render-header="addRedStar" v-for="(item, index) in columns" :label="item.label" :prop="item.prop" :width="item.width"  :key="index" align="center" >
                                <template slot-scope="scope">
                                    <template v-if="item.type == '1'">
                                        <el-autocomplete
                                            style="width:74%;margin-right:5px;"
                                            v-model="scope.row[item.prop]"
                                            :fetch-suggestions="searchCode"
                                            placeholder="请输入商品编码"
                                            @select="val => handleSelect(val, scope.row, scope.$index)"
                                            @input="val => onChangeInput(val, scope.row)"
                                        ></el-autocomplete>
                                        <el-button type="primary" size="small" class="btn-success" icon="el-icon-search" @click="searchProductSku(scope.$index)"></el-button>
                                    </template>
                                    <template v-if="item.type == '2'">
                                        <el-autocomplete
                                            style="width:74%;margin-right:5px;"
                                            v-model="scope.row[item.prop]"
                                            :fetch-suggestions="searchName"
                                            placeholder="请输入商品名称"
                                            @select="val => handleSelect(val, scope.row, scope.$index)"
                                            @input="val => onChangeInput(val, scope.row)"
                                        ></el-autocomplete>
                                        <el-button type="primary" size="small" class="btn-success" icon="el-icon-search" @click="searchProductSku(scope.$index)"></el-button>
                                    </template>
                                    <template v-if="item.type == '3'">{{ scope.row[item.prop] }}</template>
                                    <template v-if="item.type == 'usageAmount'">
                                        <el-input placeholder="" v-model="scope.row[item.prop]" @input="(val) => inputNum(val, scope.row, 'usageAmount')" />
                                    </template>
                                    <template v-if="item.type == 'lossAmount'">
                                        <el-input placeholder="" v-model="scope.row[item.prop]" @input="(val) => inputNum(val, scope.row, 'lossAmount')" />
                                    </template>
                                    <template v-if="item.type == 'ifBom'">
                                        {{ scope.row.ifBom == '0' ? '否' : scope.row.ifBom == '1' ? '是' : '' }}
                                    </template>
                                    <template v-if="item.type == 'replaceManner'">
                                        <el-select v-model="scope.row[item.prop]" style="width:100%;" placeholder="请选择" :disabled="scope.row.specificationId == ''" @change="val => onChangeReplaceManner(val, scope.row)">
                                            <el-option label="无替代" value="0">无替代</el-option>
                                            <el-option label="可替代" value="1">可替代</el-option>
                                        </el-select>
                                    </template>
                                    <template v-if="item.type == 'productBomCode'">
                                        <template v-if="scope.row.ifBom == '1'">
                                            <el-select v-model="scope.row[item.prop]" style="width:100%;" placeholder="请选择" @change="val => onChangeBomCode(val, scope.row)">
                                                <el-option
                                                    v-for="item in scope.row.bomList"
                                                    :key="item.id"
                                                    :label="item.code"
                                                    :value="item.code"
                                                />
                                            </el-select>
                                        </template>
                                        <template v-else>
                                            <el-select v-model="scope.row[item.prop]" style="width:100%;" placeholder="" disabled>
                                                <el-option label="1" value="1">1</el-option>
                                            </el-select>
                                        </template>
                                    </template>
                                    <template v-if="item.type == 'replaceSpecificationCode'">
                                        <template v-if="scope.row.replaceManner == '1'">
                                            <el-autocomplete
                                                style="width:74%;margin-right:5px;"
                                                v-model="scope.row[item.prop]"
                                                :fetch-suggestions="searchReplaceCode"
                                                placeholder="请输入商品编码"
                                                @select="val => selectReplaceSpecificationCode(val, scope.row)"
                                            ></el-autocomplete>
                                            <el-button type="primary" size="small" class="btn-success" icon="el-icon-search" @click="searchProductSku(scope.$index, scope.row, 'replaceProduct')"></el-button>
                                        </template>
                                        <template v-else>
                                            <el-input placeholder="" v-model="scope.row[item.prop]" disabled />
                                        </template>
                                    </template>
                                    <template v-if="item.type == 'handle'">
                                        <el-link class="link-success mr10" @click="addRow(scope.row, 'add')">新建一行</el-link>
                                        <el-link type="danger" @click="deleteRow(scope.$index)">删除一行</el-link>
                                    </template>
                                </template>
                            </el-table-column>
                        </el-table>
                    </el-col>
                </el-row>
            </el-form>
        </div>
        <!-- sku分类列表 -->
        <el-dialog :visible.sync="bomSkuListShow" width="800px" top="50px" append-to-body center>
            <el-table :data="searchClassSkuList" @row-click="handleClassSkuList">
                <el-table-column label="序号" type="index" align="center" width="50">
                    <template slot-scope="scope">
                        <span>{{(queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1}}</span>
                    </template>
                </el-table-column>
                <el-table-column label="编码" align="center" prop="specificationCode" />
                <el-table-column label="名称" align="center" prop="specificationName" />
            </el-table>
            <pagination
                v-show="total > 0"
                :total="total"
                :page.sync="queryParams.pageNum"
                :limit.sync="queryParams.pageSize"
                @pagination="getClassList()"
            />
        </el-dialog>
        <!-- 根据品名查询所有产品规格 -->
        <el-dialog :visible.sync="bomSkuProductListShow" width="800px" top="50px" append-to-body center>
            <el-table :data="searchClassSkuProductList" @row-click="handleClassSkuProductList">
                <el-table-column label="序号" type="index" align="center" width="50">
                    <template slot-scope="scope">
                        <span>{{(productQueryParams.pageNum - 1) * productQueryParams.pageSize + scope.$index + 1}}</span>
                    </template>
                </el-table-column>
                <el-table-column label="编码" align="center" prop="specificationCode" />
                <el-table-column label="名称" align="center" prop="specificationName" />
            </el-table>
            <pagination
                v-show="productTotal > 0"
                :total="productTotal"
                :page.sync="productQueryParams.pageNum"
                :limit.sync="productQueryParams.pageSize"
                @pagination="getBomSkuProductList()"
            />
        </el-dialog>
    </div>
</template>

<script>
import { bomEdit, bomSkuList, bomDetail } from "@/api/system/bom/bom"
import { listProduct } from "@/api/system/basicdata/basicdata"
export default {
    name: "add",
    data() {
        return {
            form: {
                code: '', // 单据编号
                specificationId: '', // 品名id
                specificationName: '', // 品名
                specification: '', // 规格
                unit: '', // 单位
                effectiveTime: '', // 生效时间
                failureTime: '', // 失效时间
                version: '', // 版本号
                remark: '', // 备注
                detailList: []
            },
            // 日期控制
            pickerOptions: {
                // disabledDate(time) {
                //     return time.getTime() < Date.now() - 24 * 60 * 60 * 1000
                // }
            },
            // 表单校验
            rules: {
                code: [
                    { required: true, message: "编码不能为空", trigger: "blur" }
                ],
                specificationName: [
                    { required: true, message: "品名不能为空", trigger: "blur" }
                ],
                effectiveTime: [
                    { required: true, message: "生效时间不能为空", trigger: "blur" }
                ],
                failureTime: [
                    { required: true, message: "失效时间不能为空", trigger: "blur" }
                ]
            },
            skuProList: [],
            show: false,
            // 产品数据
            searchProductList: [],
            // 表头
            columns: [{
                prop: "specificationCode",
                label: "物料编码",
                width: 250,
                type: '1'
            },{
                prop: "specificationName",
                label: "名称",
                width: 250,
                type: '2'
            },{
                prop: "unit",
                label: "单位",
                width: 100,
                type: '3'
            },{
                prop: "usageAmount",
                label: "使用量",
                width: 120,
                type: 'usageAmount'
            },{
                prop: "lossAmount",
                label: "损耗量",
                width: 120,
                type: 'lossAmount'
            },{
                prop: "specification",
                label: "规格尺寸",
                width: 100,
                type: '3'
            },{
                prop: "ifBom",
                label: "是否BOM",
                width: 100,
                type: 'ifBom'
            },{
                prop: "productBomCode",
                label: "BOM编号",
                width: 120,
                type: 'productBomCode'
            },{
                prop: "version",
                label: "版本号",
                width: 100,
                type: '3'
            },{
                prop: "replaceManner",
                label: "替代方式",
                width: 120,
                type: 'replaceManner'
            },{
                prop: "replaceSpecificationCode",
                label: "物料编码",
                width: 250,
                type: 'replaceSpecificationCode'
            },{
                prop: "replaceSpecificationName",
                label: "物料名称",
                width: 180,
                type: '3'
            },{
                label: "",
                type: 'handle',
                width: 150
            }],
            // 表格数据
            productData: [{
                specificationId: '', // 物料id
                specificationName: '', // 物料名称
                specificationCode: '', // 物料编码
                unit: '', // 单位
                usageAmount: '', // 使用量
                lossAmount: '', // 损耗量
                specification: '', // 规格尺寸
                ifBom: '', // 是否BOM: 0否 1是
                productBomId: '', // Bom_id
                productBomCode: '', // Bom编码
                version: '', // 版本号
                replaceManner: '', // 替换方式：0无替代 1可替代
                replaceSpecificationId: '', // 物料id
                replaceSpecificationCode: '', // 物料编码
                replaceSpecificationName: '', // 物料名称
            }],
            bomSkuListShow: false,
            searchClassSkuList: [],
            total: 0,
            queryParams: {
                pageNum: 1,
                pageSize: 10,
                productProperties: 1,
                productStatus: 1, 
                approvalStatus: 2
            },
            bomSkuProductListShow: false,
            searchClassSkuProductList: [],
            productTotal: 0,
            productQueryParams: {
                pageNum: 1,
                pageSize: 10,
                filterParam: undefined,
                filterParam2: undefined
            },
            index: '',
            productType: '',
            searchProductReplaceList: [],
            productReplace: {}
        }
    },
    created() {
        this.getDetail()
    },
    methods: {
        // 获取详细信息
        getDetail(){
            bomDetail(this.$route.query.id).then(res => {
                if(res.code == 200){
                    this.form = res.data
                    this.productData = res.data.detailList
                    res.data.detailList.forEach(item => {
                        if(item.lossAmount == 0 || item.lossAmount == null){
                            item.lossAmount = ''
                        }
                    })
                    this.getBomSkuList()
                }
            })
        },
        onChangeName(val){
            if(val !== ''){
                this.show = true
                // 查询sku列表
                listProduct({productProperties: 1, searchValue: val, productStatus: 1, approvalStatus: 2}).then(res => {
                    this.skuProList = res.rows
                })
            }else{
                this.show = false
            }
        },
        check(item) {
            this.form.specificationId = item.productSpecificationsId
            this.form.specificationName = item.specificationName
            this.form.unit = item.unit
            this.show = false
            this.getBomSkuList()
            this.productData = []
            this.addRow()
        },
        // 点击弹窗sku列表
        onBomSkuList(){
            this.bomSkuListShow = true
            this.getClassList()
        },
        // sku列表
        getClassList(){
            listProduct(this.addDateRange(this.queryParams)).then(res => {
                this.searchClassSkuList = res.rows
                this.total = res.total
            })
        },
        handleClassSkuList(row){
            this.bomSkuListShow = false
            this.show = false
            this.form.specificationId = row.productSpecificationsId
            this.form.specificationName = row.specificationName
            this.form.unit = row.unit
            this.getBomSkuList()
            this.productData = []
            this.addRow()
        },
        // 生效时间
        onChangeEffectiveTime(e){
            var date = new Date(e)
            this.effectiveTime = date.getTime()
            if(this.failureTime == undefined || this.failureTime == ''){
                // console.log('111')
            }else{
                if(this.effectiveTime >= this.failureTime){
                this.form.effectiveTime = ''
                this.effectiveTime = ''
                this.$modal.msgError('生效日期必须小于失效日期！')
                }
            }
        },
        // 失效时间
        onChangeFailureTime(e){
            var date = new Date(e)
            this.failureTime = date.getTime()
            if(this.form.failureTime != null){
                if(this.failureTime > new Date(this.form.effectiveTime).getTime()){
                    // console.log('111')
                }else{
                    this.form.failureTime = ''
                    this.failureTime = ''
                    this.$modal.msgError('失效时间不能小于生效日期！')
                }
            }else{
                if(this.effectiveTime > 0){
                    if(this.failureTime > this.effectiveTime){
                        // console.log('111')
                    }else{
                        this.form.failureTime = ''
                        this.failureTime = ''
                        this.$modal.msgError('失效时间不能小于生效日期！')
                    }
                }else{
                    this.form.failureTime = ''
                    this.failureTime = ''
                    this.$modal.msgError('生效日期不能为空！')
                }
            }
        },
        // 表头添加*
        addRedStar(h, { column }){
            if(column.property == 'specificationCode' || column.property == 'specificationName' || column.property == 'usageAmount'){
                return [
                    h("span", { style: "color: red" }, "*"),
                    h("span", " " + column.label),
                ]
            }else{
                return column.label
            }
        },
        // 获取产品信息
        getBomSkuList(){
            bomSkuList({filterParam: this.form.specificationId}).then(res => {
                this.searchProductList = res.rows
            })
        },
        // 编码搜索
        searchCode(val, cb){
            let list = []
            this.searchProductList.map(item => {
                list.push(Object.assign(
                    {},item,{
                        value: item.specificationCode
                    }
                ))
            })
            var arr = list
            var results = val ? arr.filter(this.createFilter(val)) : arr
            cb(results)
        },
        // 名称搜索
        searchName(val, cb){
            let list = []
            this.searchProductList.map(item => {
                list.push(Object.assign(
                    {},item,{
                        value: item.specificationName
                    }
                ))
            })
            var arr = list
            var results = val ? arr.filter(this.createFilter(val)) : arr
            cb(results)
        },
        // 匹配
        createFilter(val) {
            return (res) => {
                return (res.value.toLowerCase().indexOf(val.toLowerCase()) === 0)
            }
        },
        // 选中产品
        handleSelect(item, row, index){
            // console.log(item)
            row.specificationName = item.specificationName // 物料名称
            row.specificationId = item.productSpecificationsId // 物料id
            row.specificationCode = item.specificationCode // 物料编码
            row.unit = item.unit // 单位
            row.usageAmount = ''
            // row.specification = item.value1 + item.value2 // 规格尺寸
            row.ifBom = item.ifBom // 是否BOM: 0否 1是
            row.productBomCode = item.productBomCode //  bom编号
            row.bomList = item.bomList // bom编号列表
            row.version = item.bomVersion // 版本号
            row.replaceManner = '0' // 替换方式：0无替代 1可替代
            // 判断编码是否重复
            let arr = this.productData.filter(item => item.specificationCode !== '')
            if(arr && arr.length > 0){
                let productCode = arr.map(i => i.specificationCode)
                let productCodeSet = new Set(productCode)
                if(productCodeSet.size == productCode.length){
                    let newArr = this.productData.filter(item => item.specificationCode !== '')
                    this.productData = newArr
                }else{
                    this.$modal.msgError('产品已存在，请重新选择！')
                    this.productData.splice(index, 1)
                    this.addRow()
                }
            }
        },
        // 验证商品编码/商品名称
        onChangeInput(val, item){
            if(this.form.specificationName == ''){
                this.$modal.msgError('品名不能为空！')
                item.specificationCode = ''
                item.specificationName = ''
            }else if(this.form.specificationId == ''){
                this.$modal.msgError('品名信息不正确，请重新填写！')
                item.specificationCode = ''
                item.specificationName = ''
            }
        },
        // 根据品名查询所有产品规格
        searchProductSku(index, row, type){
            if(this.form.specificationName == ''){
                this.$modal.msgError('品名不能为空！')
            }else if(this.form.specificationId == ''){
                this.$modal.msgError('品名信息不正确，请重新填写！')
            }else{
                if(type == 'replaceProduct'){
                    this.productType = '1'
                    this.productReplace = row
                    this.productQueryParams.filterParam2 = row.specificationId
                }else{
                    this.productType = '0'
                    // this.productQueryParams.filterParam = this.form.specificationId
                }
                this.productQueryParams.filterParam = this.form.specificationId
                this.bomSkuProductListShow = true
                this.index = index
                this.getBomSkuProductList()
            }
        },
        getBomSkuProductList(){
            bomSkuList(this.addDateRange(this.productQueryParams)).then(res => {
                this.searchClassSkuProductList = res.rows
                this.productTotal = res.total
            })
        },
        handleClassSkuProductList(row){
            // console.log(row)
            this.bomSkuProductListShow = false
            if(this.productType == '0'){
                let obj = {
                    specificationId: row.productSpecificationsId,
                    specificationCode: row.specificationCode,
                    specificationName: row.specificationName,
                    // specification: data.value1 + data.value2,
                    usageAmount: '',
                    unit: row.unit,
                    ifBom: row.ifBom,
                    productBomCode: row.productBomCode,
                    version: row.bomVersion,
                    bomList: row.bomList,
                    replaceManner: '0'
                }
                if(this.productData.length == 0){
                    this.productData.push(obj)
                }else{
                    let idx = this.productData.findIndex(item => item.specificationCode == row.specificationCode)
                    if(idx > -1){
                        this.$modal.msgError('产品已存在，请重新选择！')
                    }else{
                        this.$set(this.productData, this.index, obj)
                    }
                }
            }else{
                this.productReplace.replaceSpecificationId = row.productSpecificationsId
                this.productReplace.replaceSpecificationCode = row.specificationCode
                this.productReplace.replaceSpecificationName = row.specificationName
                // console.log(this.productReplace)
                this.$set(this.productData, this.index, this.productReplace)
            }
        },
        // 选择bom编号更改版本号
        onChangeBomCode(val, row){
            let bomCode = row.bomList.find(item => item.code == val)
            row.version = bomCode.version
        },
        // 替代方式
        onChangeReplaceManner(val, row){
            if(val == '1'){
                bomSkuList({filterParam: row.specificationId}).then(res => {
                    this.searchProductReplaceList = res.rows
                })
            }else{
                row.replaceSpecificationName = ''
                row.replaceSpecificationId = ''
                row.replaceSpecificationCode = ''
            }
        },
        // 替代物料编码搜索
        searchReplaceCode(val, cb){
            let list = []
            this.searchProductReplaceList.map(item => {
                list.push(Object.assign(
                    {},item,{
                        value: item.specificationCode
                    }
                ))
            })
            var arr = list
            var results = val ? arr.filter(this.createFilter(val)) : arr
            cb(results)
        },
        // 替代产品
        selectReplaceSpecificationCode(item, row){
            row.replaceSpecificationName = item.specificationName
            row.replaceSpecificationId = item.productSpecificationsId
            row.replaceSpecificationCode = item.specificationCode
        },
        // 使用量/损耗量验证
        inputNum(val, row, type){
            if(type == 'usageAmount'){
                if(val == '' || val == undefined){
                    this.$modal.msgError('使用量不能为空!')
                    row.usageAmount = ''
                }else{
                    if(/^[1-9]\d*$|^0$/.test(val) == false){
                        this.$modal.msgError('使用量必须是数字！')
                        row.usageAmount = ''
                        return false
                    }else{
                        if(JSON.parse(val) <= 0){
                            row.usageAmount = ''
                            this.$modal.msgError('使用量必须大于0!')
                        }
                    }
                }
            }else{
                if(/^[1-9]\d*$|^0$/.test(val) == false){
                    this.$modal.msgError('损耗量必须是数字！')
                    row.lossAmount = ''
                    return false
                }else{
                    if(JSON.parse(val) <= 0){
                        row.lossAmount = ''
                        this.$modal.msgError('损耗量必须大于0!')
                    }
                }
            }
        },
        // 新建一行
        addRow(row, type){
            if(type == 'add'){
                let usageAmount = this.productData.every(val => !!val.usageAmount)
                if(row.specificationId !== ''){
                    if(row.usageAmount !== ''){
                        if(usageAmount == true){
                            let data = {
                                key: {
                                    specificationId: ''
                                }
                            }
                            this.columns.forEach(item =>{
                                data.key[item.prop] = ''
                            })
                            this.productData.push(JSON.parse(JSON.stringify(data.key)))
                        }else{
                            this.$modal.msgError('信息不完整，不能新建！')
                        }
                    }else{
                        this.$modal.msgError('使用量不能为空！')
                    }
                }else{
                    this.$modal.msgError('产品信息不能为空！')
                }
            }else{
                let data = {
                    key: {
                        specificationId: ''
                    }
                }
                this.columns.forEach(item =>{
                    data.key[item.prop] = ''
                })
                this.productData.push(JSON.parse(JSON.stringify(data.key)))
            }
        },
        // 删除数据
        deleteRow(index){
            this.$modal.confirm('是否确认删除当前数据？', '删除').then(() => {
                this.productData.splice(index, 1)
                if(this.productData.length == 0){
                    this.addRow()
                }
            }).catch(() => {})
        },
        // 确定
        submitForm(){
            this.$refs["form"].validate(valid => {
                if (valid) {
                    let arr = this.productData.filter(item => item.specificationCode !== '')
                    this.form.detailList = arr
                    let usageAmount = arr.every(val => !!val.usageAmount)
                    if(arr.length > 0){
                        if(usageAmount == true){
                            let arr = this.form
                            arr.approvalStatus = '0'
                            bomEdit(arr).then(res => {
                                if(res.code == 200){
                                    this.$modal.msgSuccess("操作成功")
                                    this.$tab.closeOpenPage({ path: "/bom/list" })
                                }
                            })
                        }else{
                            this.$modal.msgError('使用量不能为空！')
                        }
                    }else{
                        this.$modal.msgError('请选择商品！')
                    }
                }
            })
        }
    }
}
</script>

<style scoped>
.options {
    position: absolute;
    z-index:10;
    left:0;
    width: 82%;
}
.options li {
    height: 40px;
    line-height: 40px;
    cursor: pointer;
    border: 1px solid #DCDFE6;
    border-top: 0px;
    text-indent: 12px;
    overflow: hidden;
}
.options li:hover {
    background: #f3f5f9;
    color: #606266;
}
.options-item{
    background:#fff;
    overflow-y:scroll;
    max-height: 200px;
}
.link-success,.link-success.el-link.el-link--default:hover {
    color: #28C6C6;
}
.link-success.el-link.is-underline:hover:after{
    border-bottom: 1px solid #28C6C6;
}
</style>